#include <algorithm>
#include <cstdio>

typedef long long ll;
const int N = 1000005, bit = 21, inf = 0xf3f3f3f;
int n, top, q, cnt, k, f[bit][N], dep[N], dfn[N], stk[N], a[N], mmin[N],
    mmax[N], siz[N], maxx, minn = inf;
int e_cnt, v_cnt, heads[N], vheads[N];
bool key[N];
ll summ;

struct Edge {
  int v, nxt, w;
} e[N << 1], g[N << 1];

inline void add(int u, int v, int w, int *heads, Edge *e, int &e_cnt) {
  e[++e_cnt].v = v, e[e_cnt].nxt = heads[u], heads[u] = e_cnt, e[e_cnt].w = w;
}

void dfs(int x, int fa) {
  dfn[x] = ++cnt;
  for (int i = heads[x], v; i; i = e[i].nxt) {
    if ((v = e[i].v) != fa) {
      dep[v] = dep[x] + 1;
      f[0][v] = x;
      dfs(v, x);
    }
  }
}

inline int lca(int x, int y) {
  if (dep[x] < dep[y]) std::swap(x, y);
  for (int i = bit - 1; ~i; --i)
    if (dep[f[i][x]] >= dep[y]) x = f[i][x];
  if (x == y) return x;
  for (int i = bit - 1; ~i; --i)
    if (f[i][x] != f[i][y]) x = f[i][x], y = f[i][y];
  return f[0][x];
}

inline void link(int x, int y) {
  if (dep[x] < dep[y]) std::swap(x, y);
  add(y, x, dep[x] - dep[y], vheads, g, v_cnt);
}

void solve(int x) {
  if (key[x]) siz[x] = 1;
  mmin[x] = key[x] ? 0 : inf, mmax[x] = 0;
  for (int i = vheads[x], v; i; i = g[i].nxt) {
    solve(v = g[i].v);
    siz[x] += siz[v];
    summ += 1ll * siz[v] * (k - siz[v]) * g[i].w;
    minn = std::min(minn, mmin[x] + mmin[v] + g[i].w);
    maxx = std::max(maxx, mmax[x] + mmax[v] + g[i].w);
    mmin[x] = std::min(mmin[x], mmin[v] + g[i].w);
    mmax[x] = std::max(mmax[x], mmax[v] + g[i].w);
  }
  key[x] = false;
}

inline bool cmp(const int &lhs, const int &rhs) { return dfn[lhs] < dfn[rhs]; }

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
  freopen("P4103 [HEOI2014]大工程.in", "r", stdin);
  freopen("P4103 [HEOI2014]大工程.out", "w", stdout);
#endif
#endif

  scanf("%d", &n);
  for (int i = 1, u, v; i < n; ++i) {
    scanf("%d%d", &u, &v);
    add(u, v, 1, heads, e, e_cnt), add(v, u, 1, heads, e, e_cnt);
  }
  dep[1] = 1;
  dfs(1, 1);
  for (int i = 1; i < bit; ++i)
    for (int j = 1; j <= n; ++j) f[i][j] = f[i - 1][f[i - 1][j]];
  scanf("%d", &q);
  while (q--) {
    scanf("%d", &k);
    for (int i = 1; i <= k; ++i) {
      scanf("%d", &a[i]), key[a[i]] = true;
    }
    std::sort(a + 1, a + k + 1, cmp);
    siz[a[1]] = 0, vheads[a[1]] = 0;
    stk[top = 1] = a[1];
    for (int i = 2; i <= k; ++i) {
      int mlca = lca(a[i], stk[top]);
      if (mlca != stk[top]) {
        while (dfn[stk[top - 1]] > dfn[mlca])
          link(stk[top], stk[top - 1]), --top;
        if (stk[top - 1] != mlca)
          siz[mlca] = 0, vheads[mlca] = 0, link(stk[top], mlca), stk[top] = mlca;
        else
          link(stk[top--], mlca);
      }
      siz[mlca] = 0, vheads[a[i]] = 0, stk[++top] = a[i];
    }
    for (int i = 1; i < top; ++i) link(stk[i], stk[i + 1]);
    solve(stk[1]);
    printf("%lld %d %d\n", summ, minn, maxx);
    summ = 0, minn = inf, maxx = 0, v_cnt = 0;
  }
  return 0;
}